<%@ include file="/view/template/header.jsp"%>	
	<div id="content">
    	<%@ include file="/view/ehr/ehr_common.jsp"%>
        		<div class="right-content">
			<div class="box">
				<s:form action="select_ward">
					<div>
						<s:select key="ward.wardNo" cssClass="select_box" list="#{'1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', '10': '10'}" headerKey="1" headerValue="---Select Ward---"/>
						<s:hidden key="ward.patient_id" value="%{#parameters['patient_id'][0]}"/>
						<s:submit key="ward.submit" cssClass="green" align="center"/>
					</div>
				</s:form>


				<div class="brown-box">
					<c:set var="bedsList" value="${occupiedBeds}" scope="page" />
						<% String bed_list=(String)pageContext.getAttribute("bedsList",PageContext.PAGE_SCOPE);
						%>
						<s:if test="%{isReply}">
							<s:if test="%{isWardEmpty}">
								<% for(int i=0; i<16; i++){ %>
									<div class="bed-box">
										<span><%out.println(i+1);%></span>
										<s:url action="admit_patient_to_unoccupied_bed" var="admit_patient_to_unoccupied_bed_action">
											<s:param name="patient_id" value="%{ward.patient_id}"/>
											<s:param name="ward_no" value="%{ward.wardNo}"/>
											<s:param name="bed_no"><%out.println(i+1);%></s:param>
										</s:url>
										<a href="${admit_patient_to_unoccupied_bed_action}"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a>
									</div>
								<%} %>
							</s:if>
							<s:else>
						<%
							
							String[] beds=bed_list.split(",");
							for(int i=0; i<16; i++) {
								Boolean isAssigned=false;
								for(int j=0; j<beds.length; j++){
									if(beds[j].length()!=0 && Integer.parseInt(beds[j])==(i+1)){%>
										<div class="bed-box">
											<span><%out.println(i+1);%></span>
											<s:url action="view_patient_detials_occupied_bed" var="view_patient_detials_occupied_bed_action">
												<s:param name="ward_no" value="%{ward.wardNo}"/>
												<s:param name="bed_no"><%out.println(i+1);%></s:param>
											</s:url>
											<a href="${view_patient_detials_occupied_bed_action}"><img src="view/template/images/bed-full.jpg" class="img-bed"/></a>
										</div>
								<%  isAssigned=true;
									break;
									}
								}
								if(!isAssigned){ %>
									<div class="bed-box">
										<span><%out.println(i+1);%></span>
										<s:url action="admit_patient_to_unoccupied_bed" var="admit_patient_to_unoccupied_bed_action">
											<s:param name="patient_id" value="%{ward.patient_id}"/>
											<s:param name="ward_no" value="%{ward.wardNo}"/>
											<s:param name="bed_no"><%out.println(i+1);%></s:param>
										</s:url>
										<a href="${admit_patient_to_unoccupied_bed_action}"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a>
									</div>
								<%	
								}
						} %>
							</s:else>
						</s:if>
						<s:else>
							<div class="bed-box"><span>1</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>2</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>3</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>4</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>5</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>6</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>7</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>8</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    
						    <div class="bed-box"><span>9</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>10</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>11</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>12</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>13</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>14</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>15</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    <div class="bed-box"><span>16</span><a href="#"><img src="view/template/images/bed-empty.jpg" class="img-bed"/></a></div>
						    </s:else>
						</div>
					</div>
				</div>
			</div>
	<%@ include file="/view/template/footer.jsp"%>